package com.smh.a03MapDemo3;

import java.util.*;

public class Test {
    public static void main(String[] args) {

        Random random = new Random();

        Map<Student,Character> map = new HashMap<>();

        for (int i = 0; i < 80; i++) {
            char temp = (char) (random.nextInt(4)+'A');
            Student student = new Student("asd",random.nextInt(5)+12);
            map.put(student,temp);
        }
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 0;

        map.forEach((s,ch)->{
            System.out.println(s+" "+ch);
        });

        Set<Student> students = map.keySet();
        students.forEach(s->{
            System.out.println(s+" "+map.get(s));
        });

        Iterator<Student> iterator = students.iterator();
        while (iterator.hasNext()){
            Student student = iterator.next();
            char ch = map.get(student);
            if (ch=='A'){
                a++;
            }else
            if (ch=='B'){
                b++;
            }else
            if (ch=='C'){
                c++;
            }else
            if (ch=='D'){
                d++;
            }
        }

        System.out.println("A="+a+",B="+b+",C="+c+",D="+d);


    }
}
